package com.nuc.thread.cas;

/**
 * @author 诗酒趁年华
 * @version 1.0.0
 * @Description 加锁的方式
 * @createTime 2021年07月11日 18:05:00
 */
public class AccountUnsafe implements Account {
    private Integer balance;

    public AccountUnsafe(Integer balance) {
        this.balance = balance;
    }

    @Override
    public synchronized Integer getBalance() {
        return this.balance;
    }

    @Override
    public synchronized void withDraw(Integer amount) {
        this.balance -= amount;
    }
}
